package com.example.demo.modal;

import com.example.demo.constants.Constants;
import lombok.Data;

@Data
public class Result<T> {
    private Integer code; //200-成功 -1-用户未登录 -2-程序出错  业务状态码
    private String errMsg;
    private T Data;
    public static <T> Result success(T data){
        Result result = new Result();
        result.setCode(Constants.SUCCESS_CODE);
        result.setErrMsg("");
        result.setData(data);
        return result;
    }

    public static <T> Result unLogin(){
        Result result = new Result();
        result.setCode(Constants.UNLOGIN_CODE);
        result.setErrMsg("用户未登录");
        return result;
    }

    public static <T> Result fail(){
        Result result = new Result();
        result.setCode(Constants.FAIL_CODE);
        result.setErrMsg("程序出错");
        return result;
    }
}
